
//------------------------------------------------------------------------------

using Apps.Models;
using Apps.IDAL.CY;
using System;
using System.Linq;

namespace Apps.DAL.CY
{
    public partial class CY_MIX_CONDITIONRepository : BaseRepository<CY_MIX_CONDITION>, ICY_MIX_CONDITIONRepository, IDisposable
    {
        public CY_MIX_CONDITIONRepository(DBContainer db) : base(db)
        {

        }

        public IQueryable<CY_MIX_CONDITIONModel> QueryList(string CREW_ID)
        {
            if (string.IsNullOrWhiteSpace(CREW_ID)) CREW_ID = "$--Empty Crew ID--$";

            IQueryable<CY_MIX_CONDITIONModel> result = from r in Context.CY_MIX_CONDITION
                                                       join sf in Context.PUB_CREW on r.CREW_ID equals sf.CREW_ID into sf
                                                       from tsf in sf.DefaultIfEmpty()
                                                       where CREW_ID == "$--Empty Crew ID--$" || r.CREW_ID == CREW_ID
                                                       select new CY_MIX_CONDITIONModel()
                                                       {
                                                           CONDITION_ID = r.CONDITION_ID,
                                                           CREW_ID = r.CREW_ID,
                                                           SEASON = r.SEASON,
                                                           LOADRATE = r.LOADRATE,
                                                           MIN_LOADRATE = r.MIN_LOADRATE,
                                                           MAX_LOADRATE = r.MAX_LOADRATE,
                                                           MIN_QNETAR = r.MIN_QNETAR,
                                                           MAX_QNETAR = r.MAX_QNETAR,
                                                           MIN_VAD = r.MIN_VAD,
                                                           MAX_VAD = r.MAX_VAD,
                                                           MIN_STAD = r.MIN_STAD,
                                                           MAX_STAD = r.MAX_STAD,
                                                           MIN_AAD = r.MIN_AAD,
                                                           MAX_AAD = r.MAX_AAD,
                                                           COALCONSUMPTION = r.COALCONSUMPTION,
                                                           EXCEPTIONS = r.EXCEPTIONS,
                                                           COMPILING_USER = r.COMPILING_USER,
                                                           COMPILING_TIME = r.COMPILING_TIME,
                                                           CREW_NAME = tsf.CREW_NAME
                                                       };
            return result;
        }
    }
}
